package com.lc.dao.impl;

import com.lc.bean.Grade;
import com.lc.dao.DBUtils;
import com.lc.dao.GradeDao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: ManolinCoder
 * @time: 2021/8/22
 */
public class GradeDaoImpl extends DBUtils implements GradeDao {
    @Override
    public List<Grade> getList() {
        List gs = new ArrayList();
        String sql = "select * from grade";
        resultSet = query(sql, null);
        try {
            while (resultSet.next()){
                Grade grade = new Grade();
                grade.setGradeId(resultSet.getInt("gradeid"));
                grade.setGradeName(resultSet.getString("gradename"));
                gs.add(grade);
            }
        }catch (SQLException e){
            e.printStackTrace();
        }finally {
            closeAll();
        }
        return gs;
    }
}
